Skip to content

[wasm] Use instantiating stubs for default interface dispatch - #133924

Open
davidwrighton wants to merge 1 commit into
dotnet:mainfrom
davidwrighton:wasm-fix-default-interface-dispatch
Open

davidwrighton wants to merge 1 commit into
dotnet:mainfrom
davidwrighton:wasm-fix-default-interface-dispatch

Conversation

@davidwrighton

Copy link
Copy Markdown
Member

Summary

  • preserve instantiating-stub selection for non-generic default interface methods routed through the Wasm CORINFO_VIRTUALCALL_LDVIRTFTN path
  • remove the browser CoreCLR ReadyToRun skip from ComplexHierarchyPositive

The instantiating stub keeps the interface dispatch call site on its normal ABI while supplying the generic interface context if dispatch resolves to the shared default implementation.

Testing

  • ./build.sh clr.tools -c checked
  • src/tests/build.sh -browser -checked -test:Loader/classloader/StaticVirtualMethods/InterfaceVariance/ComplexHierarchyPositive.csproj
  • browser-wasm Checked ReadyToRun ComplexHierarchyPositive passed with exit code 100

Fixes #133466

Note

This pull request description was generated with GitHub Copilot.

Fixes dotnet#133466

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/crossgen-contrib
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The Wasm ReadyToRun dispatch change warrants final human review.

Pull request overview

This PR fixes Wasm ReadyToRun default interface dispatch and re-enables the affected regression test.

Changes:

  • Select instantiating stubs for applicable Wasm interface dispatches.
  • Remove the browser ReadyToRun test skip.
File summaries
File Summary
src/tests/Loader/classloader/StaticVirtualMethods/InterfaceVariance/ComplexHierarchyPositive.cs Re-enables browser ReadyToRun coverage.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs Adds instantiating-stub selection for Wasm default interface dispatch.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

if (!targetMethod.HasInstantiation)
{
// If it is also a default interface method call, it should go through instantiating stub.
useInstantiatingStub = useInstantiatingStub || (targetMethod.OwningType.IsInterface && !originalMethod.IsAbstract);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason why we need instantiating stubs on wasm ? They are always in danger of being interpreted and I'm wondering why would they even be needed. Isn't any method able to obtain its method context directly from the PEP.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our shared generics design currently requires the distinction, since shared generic code dispatches to other shared generic code, assuming that the generic dictionary only carries the generic context argument in it. As you note, in principle this isn't needed, since the PEP could represent that context, and we could dispatch to code pointers held in the generic dictionary instead of just getting the generic context from there. However, that would make WASM an even weirder platform than it already is, so I'd like to avoid making such a change if we can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm][R2R] variant static interface dispatch has signature mismatch

3 participants